home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bboprdr.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-03-20  |  9.4 KB  |  230 lines

  1. (*===========================================================================*)
  2. (* Display routes                                                            *)
  3. (*                                                                           *)
  4. (*   Copyright 1992 by H. Roy Engehausen.  All rights reserved.              *)
  5. (*                                                                           *)
  6. (*===========================================================================*)
  7.  
  8. (*===========================================================================*)
  9. (* Display routes                                                            *)
  10. (*===========================================================================*)
  11.  
  12. PROCEDURE disp_route(cmd_in : STRING);
  13.  
  14.   VAR
  15.     found        : BOOLEAN;
  16.     inx          : BYTE;
  17.     j            : BYTE;
  18.     match_me     : str15;
  19.     s            : str8;
  20.     this_dblk    : msg_d_ptr;
  21.     this_msg     : msg_index_ptr;
  22.     this_route   : msg_r_ptr;
  23.  
  24.   LABEL
  25.     chain_next_route;
  26.  
  27.   BEGIN;
  28.  
  29.     (*-----------------------------------------------------------------------*)
  30.     (* Check the command for validity                                        *)
  31.     (*-----------------------------------------------------------------------*)
  32.  
  33.     upcase_str_var(cmd_in);
  34.  
  35.     inx := WORDS(cmd_in);
  36.  
  37.     IF inx > 2 THEN
  38.       BEGIN;
  39.         send_message(message_err_wrd);
  40.         active_tcb^.error_sw := TRUE;
  41.         EXIT;
  42.       END;
  43.  
  44.     (*-----------------------------------------------------------------------*)
  45.     (* Extract the search pattern                                            *)
  46.     (*-----------------------------------------------------------------------*)
  47.  
  48.     match_me := subword(@cmd_in, 2, 1);
  49.  
  50.     (*-----------------------------------------------------------------------*)
  51.     (* Initialize                                                            *)
  52.     (*-----------------------------------------------------------------------*)
  53.  
  54.     found := FALSE;
  55.  
  56.     this_route := msg_route_list;
  57.  
  58.     (*-----------------------------------------------------------------------*)
  59.     (* Nothing to do????                                                     *)
  60.     (*-----------------------------------------------------------------------*)
  61.  
  62.     IF this_route = NIL THEN
  63.       send_tnc_data_str('No active routes' + cr);
  64.  
  65.     (*-----------------------------------------------------------------------*)
  66.     (* Loop thru routes                                                      *)
  67.     (*-----------------------------------------------------------------------*)
  68.  
  69.     WHILE this_route <> NIL DO
  70.       BEGIN;
  71.  
  72.         (*-------------------------------------------------------------------*)
  73.         (* Get number of paths from this route                               *)
  74.         (*-------------------------------------------------------------------*)
  75.  
  76.         j := this_route^.msg_r_routes;
  77.  
  78.         (*-------------------------------------------------------------------*)
  79.         (* Look for a match                                                  *)
  80.         (*-------------------------------------------------------------------*)
  81.  
  82.         inx := 1;
  83.  
  84.         IF match_me <> '' THEN
  85.           WHILE (inx <= j)
  86.                    AND NOT match_str(SUBWORD(@this_route^.msg_r_info, inx, 1),
  87.                                      match_me) DO
  88.             INC(inx);
  89.  
  90.         (*-------------------------------------------------------------------*)
  91.         (* If no match, chain to next                                        *)
  92.         (*-------------------------------------------------------------------*)
  93.  
  94.         IF inx > j THEN
  95.           GOTO chain_next_route;
  96.  
  97.         (*-------------------------------------------------------------------*)
  98.         (* Match found                                                       *)
  99.         (*-------------------------------------------------------------------*)
  100.  
  101.         found := TRUE;
  102.  
  103.         (*-------------------------------------------------------------------*)
  104.         (* Display route info                                                *)
  105.         (*-------------------------------------------------------------------*)
  106.  
  107.         cmd_in := this_route^.msg_r_info;
  108.         strip_var(cmd_in, 'B');
  109.         set_dollar1_parm (@cmd_in);
  110.  
  111.         send_message(message_routed_to);
  112.  
  113.         (*-------------------------------------------------------------------*)
  114.         (* Find a message for this route                                     *)
  115.         (*-------------------------------------------------------------------*)
  116.  
  117.         this_msg := find_next_msg(this_route, NIL, inx);
  118.  
  119.         (*-------------------------------------------------------------------*)
  120.         (* Handle special case of none found                                 *)
  121.         (*-------------------------------------------------------------------*)
  122.  
  123.         IF this_msg = NIL THEN
  124.           BEGIN;
  125.             send_tnc_data_str('   No messages found' + cr);
  126.             GOTO chain_next_route;
  127.           END;
  128.  
  129.         (*-------------------------------------------------------------------*)
  130.         (* Loop thru all the messages                                        *)
  131.         (*-------------------------------------------------------------------*)
  132.  
  133.         REPEAT
  134.  
  135.           (*-----------------------------------------------------------------*)
  136.           (* Get the message number                                          *)
  137.           (*-----------------------------------------------------------------*)
  138.  
  139.           STR(this_msg^.msg_i_mb.msg_number, cmd_in);
  140.           cmd_in := '  ' + this_msg^.msg_i_mb.msg_type
  141.                                                      + ' # ' + cmd_in + ' => ';
  142.  
  143.           (*-----------------------------------------------------------------*)
  144.           (* Distribution or no distribution list                            *)
  145.           (*-----------------------------------------------------------------*)
  146.  
  147.           IF inx = 0 THEN
  148.             BEGIN;
  149.  
  150.               (*-------------------------------------------------------------*)
  151.               (* Direct routing.  No distribution list                       *)
  152.               (*-------------------------------------------------------------*)
  153.  
  154.               (*-------------------------------------------------------------*)
  155.               (* Look at "@" field to determine display                      *)
  156.               (*-------------------------------------------------------------*)
  157.  
  158.               IF this_msg^.msg_i_mb.msg_to_at <> '' THEN
  159.                 BEGIN;
  160.  
  161.                   (*---------------------------------------------------------*)
  162.                   (* "@" field non blank.  Display @xxxx.xx.xx.xx            *)
  163.                   (*---------------------------------------------------------*)
  164.  
  165.                   cmd_in := cmd_in + this_msg^.msg_i_mb.msg_to_at;
  166.                   IF this_msg^.msg_i_mb.msg_to_h <> '' THEN
  167.                     cmd_in := cmd_in + '.' + this_msg^.msg_i_mb.msg_to_h;
  168.  
  169.                 END
  170.               ELSE
  171.  
  172.                   (*---------------------------------------------------------*)
  173.                   (* "@" field blank.  Display to@                           *)
  174.                   (*---------------------------------------------------------*)
  175.  
  176.                   cmd_in := cmd_in + this_msg^.msg_i_mb.msg_to + '@';
  177.             END
  178.           ELSE
  179.             BEGIN;
  180.  
  181.               (*-------------------------------------------------------------*)
  182.               (* Distribution list.  Display data                            *)
  183.               (*-------------------------------------------------------------*)
  184.  
  185.               this_dblk := find_dist_list(this_msg);
  186.               IF (inx <= this_dblk^.msg_d_no) AND (inx > 0) THEN
  187.                 cmd_in := cmd_in + this_dblk^.msg_d_array[inx].msg_d_info
  188.               ELSE
  189.                 BEGIN;
  190.                   STR(this_msg^.msg_i_mb.msg_number, s);
  191.                   cmd_in := cmd_in + '** Invalid dist = ' + s;
  192.                 END;
  193.  
  194.             END;
  195.  
  196.           (*-----------------------------------------------------------------*)
  197.           (* Send output                                                     *)
  198.           (*-----------------------------------------------------------------*)
  199.  
  200.           send_tnc_data_str(cmd_in + cr);
  201.  
  202.           (*-----------------------------------------------------------------*)
  203.           (* Chain to next message                                           *)
  204.           (*-----------------------------------------------------------------*)
  205.  
  206.           this_msg := find_next_msg(this_route, this_msg, inx);
  207.  
  208.         UNTIL this_msg = NIL;
  209.  
  210.         (*-------------------------------------------------------------------*)
  211.         (* Chain to next route                                               *)
  212.         (*-------------------------------------------------------------------*)
  213.  
  214. chain_next_route:
  215.  
  216.         this_route := this_route^.msg_r_next;
  217.  
  218.       END;
  219.  
  220.     (*-----------------------------------------------------------------------*)
  221.     (* Send final message                                                    *)
  222.     (*-----------------------------------------------------------------------*)
  223.  
  224.     IF NOT found THEN
  225.       send_tnc_data_str('No routes matched your search' + cr)
  226.     ELSE
  227.       send_message(message_op_complete);
  228.  
  229.   END;
  230.